<?php


function bbcode_format($var) {
	$search = array(
		'/\[b\](.*?)\[\/b\]/is',                                
		'/\[i\](.*?)\[\/i\]/is',                                
		'/\[u\](.*?)\[\/u\]/is',
		'/\[center\](.*?)\[\/center\]/is',
		'/\[img\](.*?)\[\/img\]/is',
		'/\[url\](.*?)\[\/url\]/is',
		'/\[url\=(.*?)\](.*?)\[\/url\]/is'
		);
 
	$replace = array(
		'<strong>$1</strong>',
		'<em>$1</em>',
		'<u>$1</u>',
		'<center>$1</center>',
		'<img src="$1" />',
		'<a href="$1">$1</a>',
		'<a href="$1">$2</a>'
		);
 
	$var = preg_replace ($search, $replace, $var);
 
	return nl2br($var);
}

?>
